package com.yauchu.toolbar;

import android.content.ClipData;
import android.view.View;
import android.view.View.DragShadowBuilder;
import android.view.View.OnLongClickListener;

import com.yauchu.kegra.graph.GraphNode;

public class ToolBarOnLongClickListener implements OnLongClickListener {
	private GraphNode node;
	
	public ToolBarOnLongClickListener(GraphNode node)
	{
		super();
		
		this.node=node;
		
	}
	@Override
	public boolean onLongClick(View v) {
		//TODO probably rewrite so ClipData would contain GraphNode copy of first object 
		
		// Create a new ClipData.
		// This is done in two steps to provide clarity. The convenience method
		// ClipData.newPlainText() can create a plain text ClipData in one step.

		// Create a new ClipData.Item from the ImageView object's tag
		// ClipData.Item item = new ClipData.Item( (CharSequence) v.getTag());

		// Create a new ClipData using the tag as a label, the plain text MIME
		// type, and
		// the already-created item. This will create a new ClipDescription
		// object within the
		// ClipData, and set its MIME type entry to "text/plain"
		ClipData dragData = ClipData.newPlainText("Name",node.getGenericStringRepresentation());
		// Instantiates the drag shadow builder.
		View.DragShadowBuilder myShadow = new DragShadowBuilder(node.imageView);

		// Starts the drag

		v.startDrag(dragData, // the data to be dragged
				myShadow, // the drag shadow builder
				null, // no need to use local data
				0 // flags (not currently used, set to 0)
		);

		return false;
	}

}
